﻿@model List<GameSchool.Models.ViewModels.LevelViewModel>

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/Content/css/levels.css" />
<link rel="stylesheet" type="text/css" href="/Content/css/fab4.css" />

 @foreach (var m in Model)
 {
                   <section class="levelItem" id="level-@m.levelNumber">
                           
                           <fieldset>
                           
                                <legend class="levelheader"><span class="toggleIcon">+</span>Borð @m.levelNumber  Stig: @m.levelPoints/@m.levelMaxPoints Sæti: @m.position </legend>
                           
                                <div class="assignment">
                                   <table>
                                    <tr><th>Tegund:</th><th>Titill:</th><th>Stig:</th><th>Bónusstig:</th><th class="assignmentPos">Sæti:</th><th>Staða:</th>@if(Model.Count() == 0 || Model[0].isTeacher == true){<th>Gefa stig</th>}</tr>
                                    
                                      
                                        @foreach (var assignment in m.assignmentList)
                                        {
                                           
                                            <tr class>                                    

                                                    <td class="assignmentType">@if (@assignment.assignmentType == "HandIn")
                                                                               {<text>Verkefni</text>}
                                                                               @if (@assignment.assignmentType == "Lecture")
                                                                               {<text>Fyrirlestur</text>}                                                             
                                                                               @if (@assignment.assignmentType == "Quiz")
                                                                               {<text>Próf</text>}  </td>                                                                          
                                                                       
                                                    <td class="assignmentTitle">@Html.ActionLink(@assignment.assignmentTitle, "Display/" + @Convert.ToString(assignment.resourceID), @assignment.assignmentType)</td>                                 
                                                    <td class="assignmentPoints">@assignment.assignmentPoints / @assignment.maxPoints</td>
                                                    <td class="assignmentBonuspoints">@if (assignment.bonusPoints != 0)
                                                                                      { 
                                                                                          @assignment.bonusPoints <img src="@Url.Content("~/Content/img/design/bonuscoin.png")" id="bonuscoin" alt="bonusthingy" />
                                                                                      }
                                                                                      else { }</td>
                                                    <td class="assignmentPos">@assignment.position</td>
                                                    <td class="assignmentCompleted">@if (assignment.completed == false)
                                                                                    {<img src="@Url.Content("~/Content/img/design/unfinished.png")" class="statuspicture" alt="fin" />}
                                                                                    else
                                                                                    { <img src="@Url.Content("~/Content/img/design/finished.png")"class="statuspicture" alt="notfin" /> }</td>
                                                  
                                                  <td class="teacherRating">  
                                                                             @if(@assignment.assignmentType=="HandIn")
                                                                             {
                                                                             <a href="@Url.Action("ListHandins/" + @assignment.assignmentID, "HandIn")"><button class="ratebutton">Gefa stig</button></a>
                                                                             }
                                                                             
                                                                             
                                                                             
                                                                            
                                                                             </td>
                                                                               


                                                    </tr>
                                        }
                                                                        
                                             
                                   </table>
                                   <section class="full">
                                                    @if (User.IsInRole("Admin") || Model.Count() == 0 || Model[0].isTeacher == true)
                                                    {
                                                        <ul class="teacherLevelOptions">
                                                    <li>@Html.ActionLink("Nýr fyrirlestur", "Create/" + m.LevelID, "Lecture")</li>
                                                     <li>@Html.ActionLink("Nýtt verkefni", "Create/" + m.LevelID, "HandIn") </li>
                                                    <li>@Html.ActionLink("Nýtt próf", "Create/" + m.LevelID, "Quiz")</li>
                                                    </ul>
                                                    }</section>
                        </div>
                         </fieldset>
                        </section>
    
 }

            <style type="text/css">
                span { margin-right: 2em; color: Green; }
            
            </style>

    <script type="text/javascript">
        $(document).ready(function () {
            $(".assignment").hide();
            //toggle the componenet with class msg_body
            $(".levelheader").click(function () {
                $(this).next(".assignment").slideToggle(250);
            })//For changing plus to minus on toggle
             .toggle(function () {
                 $(this).children("span").text("-");
             }, function () {
                 $(this).children("span").text("+");
             });
        });
</script>

@{
    if (Model.Count() == 0 || Model[0].isTeacher == true)
    {
            <script type="text/javascript">
                $(document).ready(function () {

                    $("#pointsSection").hide();
                    $("#usersection").append('<h3>Stjórnborð áfanga:</h3>');

                    $("#usersection").append('<ul class="teacherPanel"><li> @Html.ActionLink("Bæta við borði", "AddLevel/" + Model[0].courseID) </li><li> @Html.ActionLink("Breyta áfangalýsingu", "EditCourse/" + Model[0].courseID) </li><li> @Html.ActionLink("Skrifa frétt", "CreateForCourse/" + Model[0].courseID, "News") </li></ul>');



                });
            </script>
    }
      }
            @section FooterScript
            {
                    @if (!User.IsInRole("admin"))
                    {
                        <script type="text/javascript">
                            $(document).ready(function () {

                        GetCoursePoints(@Model[0].courseID);

                    });
                </script>     
                    }
            }
        
             
                    
   